package com.coming.mySpring.base.service.impl;

import com.coming.mySpring.base.mapper.BaseMapper;
import com.coming.mySpring.base.query.BaseQuery;
import com.coming.mySpring.base.service.IBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/*读事务的注解   @Inherited 这个元注解用来表示该注解可以被继承 */
@Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
//@Service  这个注解不能打在这儿
public class BaseServiceImpl<T> implements IBaseService<T> {
    @Autowired
    private BaseMapper<T> baseMapper;

    @Override
    public void save(T t) {
        baseMapper.save(t);
    }

    @Override
    public void update(T t) {
        baseMapper.update(t);
    }

    @Override
    public void delete(Long id) {
        baseMapper.delete(id);
    }

    @Override
    public List<T> loadAll() {
        return baseMapper.loadAll();
    }


    @Override
    public T loadOne(Long id) {
        return baseMapper.loadOne(id);
    }

    @Override
    public Long queryCount(BaseQuery query) {
        return baseMapper.queryCount(query);
    }

    @Override
    public List<T> queryList(BaseQuery query) {
        return baseMapper.queryList(query);
    }

    @Override
    public void batchDel(List<Long> ids) {
        baseMapper.batchDel(ids);
    }
}
